# -*-coding: utf-8 -*-
"""
    @Theme   : Celery Config
    @Time    : 2024/7/13 11:04
    @Author  : YamFish
    @Url     : https://www.zhihu.com/people/yamfish
"""
import os

import dotenv
from celery.schedules import crontab


dotenv.load_dotenv()

broker_connection_retry_on_startup = True

broker_url = (
    "redis://"
    f":{os.getenv('REDIS_PASSWORD')}@" if os.getenv('REDIS_PASSWORD') else ''
    f"{os.getenv('REDIS_HOST', '127.0.0.1')}:6379/0"
)

result_backend = broker_url

enable_utc = False
beat_schedule = {
    "delete_expired_session": {
        "task": "celery_tasks.tasks.delete_expired_session",
        "schedule": crontab(minute='0', hour='0'),
    }
}
